from sympy import symbols
x = symbols("x")
y = x ** 2
x_val = 10
f_last_time = y.subs(x,x_val)
for i in range(0,100000):
    x_val -= 0.01
    f_this_time = y.subs(x, x_val)
    if f_this_time > f_last_time:
        break
    else:
        f_last_time = f_this_time
print(f"x_val:{x_val},f_this_time:{f_this_time}")